package org.jash.day7;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.viewpager2.widget.ViewPager2;

import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

import org.jash.day7.utils.StoreUtils;

public class MainActivity extends AppCompatActivity {
    private TabLayout tab;
    private ViewPager2 pager;
    private MainAdapter adapter = new MainAdapter(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        StoreUtils.init(this);
       tab = findViewById(R.id.tab);
       pager = findViewById(R.id.pager);
       pager.setAdapter(adapter);
       new TabLayoutMediator(tab, pager, (t, p) -> {
            switch (p) {
                case 0:
                    t.setIcon(R.drawable.ic_launcher_foreground);
                    t.setText("主页");
                    break;
                case 1:
                    t.setIcon(R.drawable.ic_launcher_foreground);
                    t.setText("空白");
                    break;
            }
       }).attach();
    }
}